#include <iostream>
#include <cstring>
#include "main.h"
using namespace std;

kev_handle key_group[50];
char buf[512];

int str_search(const char* src, char* dst, int num) {		//在src查找dst第n次出现的首位置
    char* tmpsrc = (char*)src;
    //int pos = 0, len = strlen(src);
    while (num--) {
        tmpsrc = strstr(tmpsrc, dst);
        if (!tmpsrc)
            return -1;
        ++tmpsrc;
    }
    return (int)(tmpsrc - src) - 1;
}
int str_split(char* dst_buf,char* src_str,char* head,int head_num,char* tail,int tail_num){
    int inde_head=0,inde_tail=0;
    if(0>(inde_head=str_search(src_str,head,head_num)))
        return -1;
    ++inde_head;        //到达目标后部字串 头
    if(0>(inde_tail=str_search(src_str,tail,tail_num)))
        return -1;
    strncpy(dst_buf,&src_str[inde_head],(size_t)(inde_tail-(inde_head)));
    return 0;
}

/*
 * @E=1@T=1@DO1=1@D=10S@M=1@B=4800@H=AA55@C=010300000001V1@D=3S@H=AA55@C=010300010001V1@D=3S
 *
 * */

int insert(char* buf){
    static int num=0;
    int i=0;
    for(;;) {
        ++i;
        if(0>str_split(key_group[num].key,buf,"@",i,"=",i))
            return num;
        ++num;
        num %= sizeof(key_group) / sizeof(kev_handle);
    }
}

int main() {
    int len=0;
    for(;;) {
        memset(buf,0,sizeof(buf));
        cin >> buf;       //接收串口数据
        if(!strncmp("break",buf,strlen("break")))
            break;
        len=insert(buf);
        for(int i=0;i<len;i++)
            printf("key: %s\n",key_group[i].key);
    }
    return 0;
}